﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for NewsUtil
/// </summary>
public class NewsUtils
{
    public NewsUtils()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public static string NewsLink(string _CateID, string _CateUrl, string _NewsID, string _TitleEn)
    {
        return Constant.HOME_PATH + _CateUrl + "/" + _TitleEn + "-" + _CateID + "-" + _NewsID + ".html";
    }

    public static string CateLink(string _CateID, string _CateUrl, string _NewsID)
    {
        return "/news/" + _CateUrl + "/" + _CateID + "-" + _NewsID + "/index.html";
    }

    public static bool CheckUrl(ref int _CateID, ref int _NewsID)
    {
        try
        {
            string p = HttpContext.Current.Request["p"];
            //cate	tin-tuc/1-100
            //news	tin-tuc/ha-noi-mo-rong-ve-phia-tay-2-100

            p = p.Replace("/", "-");
            string[] list = p.Split('-');
            _NewsID = Convert.ToInt32(list[list.Length - 1]);
            _CateID = Convert.ToInt32(list[list.Length - 2]);

            return true;
        }
        catch
        {
            return false;
        }
    }
}
